import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';
import Login from '../views/Login.vue';
import Register from '../views/Register.vue';
import Own from '../views/Own.vue';
import EditOwn from '../views/EditOwn.vue';
import Category from '../views/Category.vue';
import Address from '../views/Address.vue';
import Setting from '../views/Setting.vue';
import ForgetPassWorda from '../views/ForgetPassWorda.vue';
import ForgetPassWordb from '../views/ForgetPassWordb.vue';
import EditMb from '../views/EditMb.vue';
import Coupon from '../views/Coupon.vue';
import ProductDetail from '../views/ProductDetail.vue';
import Cart from '../views/Cart.vue';
import BeforePay from '../views/BeforePay.vue';
import Order from '../views/Order.vue';

Vue.use(VueRouter);

// 路由重复报错处理
const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
  },
  {
    path: '/register',
    name: 'Register',
    component: Register,
  },
  {
    path: '/own',
    name: 'Own',
    component: Own,
  },
  {
    path: '/eo',
    name: 'EditOwn',
    component: EditOwn,
  },
  {
    path: '/category',
    name: 'Category',
    component: Category,
  },
  {
    path: '/address',
    name: 'Address',
    component: Address,
  },
  {
    path: '/setting',
    name: 'Setting',
    component: Setting,
  },
  {
    path: '/fpwa',
    name: 'ForgetPassWorda',
    component: ForgetPassWorda,
  },
  {
    path: '/fpwb',
    name: 'ForgetPassWordb',
    component: ForgetPassWordb,
  },
  {
    path: '/emb',
    name: 'EditMb',
    component: EditMb,
  },
  {
    path: '/cou',
    name: 'Coupon',
    component: Coupon,
  },
  {
    path: '/pd',
    name: 'ProductDetail',
    component: ProductDetail,
  },
  {
    path: '/cart',
    name: 'Cart',
    component: Cart,
  },
  {
    path: '/bp',
    name: 'BeforePay',
    component: BeforePay,
  },
  {
    path: '/order',
    name: 'Order',
    component: Order,
  },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
});

export default router;
